<include file="Layout/header" />
<body>
<div class="breadcrumbs" id="breadcrumbs"> 
  <script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>
  <ul class="breadcrumb">
    <li> <i class="icon-home home-icon"></i> <a href="{:U('Admin/Index/welcome')}">首页</a> </li>
    <li class="active">新增会员</li>
  </ul>
</div>
<div class="page-content">
  <div class="page-header">
    <h1> 会员管理 <small> <i class="icon-double-angle-right"></i>新增会员</small> </h1>
  </div>
  <div class="row">
     
    <div class="col-xs-12">
      <form class="form-horizontal" action="{:U('Admin/Member/member_add')}" id="validation-form" method="post" enctype="multipart/form-data">
       <div class="">
                  <div id="user-profile-3" class="user-profile row">
                    <div class="col-sm-offset-1 col-sm-10">
                       <div class="space"></div>
                      
                        <div class="tabbable">
                          <ul class="nav nav-tabs padding-16">
                            <li class="active">
                              <a data-toggle="tab" href="#edit-basic">
                                <i class="green icon-edit bigger-125"></i>
                                基本信息
                              </a>
                            </li>

                            <li>
                              <a data-toggle="tab" href="#edit-settings">
                                <i class="purple icon-cog bigger-125"></i>
                                设置
                              </a>
                            </li>

                             
                          </ul>

                          <div class="tab-content profile-edit-tab-content">
                            <div id="edit-basic" class="tab-pane in active">
                              <h4 class="header blue bolder smaller">常规</h4>

                              <div class="row">
                                <div class="col-xs-12 col-sm-4">
                                  <input type="file" name="member_avatar"/>
                                </div>

                                <div class="vspace-xs"></div>

                                <div class="col-xs-12 col-sm-8">
                                  <div class="form-group">
                                     <div class="col-sm-9">
                                        <div class="input-medium">
                                          <img src="/data/upload/avatar/default-m.png" width="127" height="127">
                                        </div>
                                      </div>
                                  </div>
                                  <div class="space-4"></div>
                                </div>
                              </div>
                              <hr />
                              <div class="form-group">
                                    <label class="col-sm-3 control-label no-padding-right" for="member_name">会员名称</label>
                                    <div class="col-sm-9">
                                       <div class="input-medium">
                                         <div class="input-group">
                                          <input class="col-xs-12 col-sm-10" type="text" id="member_name"  placeholder="会员名称"  name="member_name" />
                                         </div>
                                      </div>
                                    </div>
                              </div>
                              <div class="form-group">
                                    <label class="col-sm-3 control-label no-padding-right" for="true_name">真实姓名</label>
                                    <div class="col-sm-9">
                                       <div class="input-medium">
                                         <div class="input-group">
                                          <input class="col-xs-12 col-sm-10" type="text" id="true_name"  placeholder="真实姓名"  name="true_name" />
                                          </div>
                                        </div>
                                    </div>
                                  </div>    
                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-date">生日</label>
                                <div class="col-sm-9">
                                  <div class="input-medium">
                                    <div class="input-group">
                                      <input class="input-me dium date-picker" id="form-field-date" type="text" data-date-format="yyyy-mm-dd" placeholder="yyyy-mm-dd" name="birthday" />
                                      <span class="input-group-addon">
                                        <i class="icon-calendar"></i>
                                      </span>
                                    </div>
                                  </div>
                                </div>
                              </div>

                              <div class="space-4"></div>

                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right">性别</label>

                                <div class="col-sm-9">
                                  <label class="inline">
                                    <input type="radio" class="ace" name="sex" value="1" <if condition="$member.sex eq 1">checked</if> />
                                    <span class="lbl"> 男</span>
                                  </label>

                                  &nbsp; &nbsp; &nbsp;
                                  <label class="inline">
                                    <input type="radio" class="ace" name="sex" value="2" <if condition="$member.sex eq 2">checked</if>  />
                                    <span class="lbl"> 女</span>
                                  </label>

                                  &nbsp; &nbsp; &nbsp;
                                  <label class="inline">
                                    <input type="radio" class="ace" name="sex" value="0" <if condition="$member.sex eq 0">checked</if>  />
                                    <span class="lbl"> 保密</span>
                                  </label>
                                </div>
                              </div>

                              <div class="space-4"></div>

                               

                              <div class="space"></div>
                              <h4 class="header blue bolder smaller">联系方式</h4>

                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="member_email">邮箱</label>

                                <div class="col-sm-9">
                                  <span class="input-icon input-icon-right">
                                    <input type="email" id="member_email" name="member_email" value="{$member.member_email}" />
                                    <i class="icon-envelope"></i>
                                  </span>
                                </div>
                              </div>

                              <div class="space-4"></div>

                               

                              <div class="space-4"></div>

                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="member_mobile">手机号</label>

                                <div class="col-sm-9">
                                  <span class="input-icon input-icon-right">
                                    <input class="input-medium input-mask-phone" type="text" id="member_mobile" name="member_mobile"  />
                                    <i class="icon-phone icon-flip-horizontal"></i>
                                  </span>
                                </div>
                              </div>

                              <div class="space"></div>
                              <h4 class="header blue bolder smaller">社交</h4>

                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="qq">QQ</label>

                                <div class="col-sm-9">
                                  <span>
                                    <input type="text" value="" id="qq" name="qq" />
                                     
                                  </span>
                                </div>
                              </div>

                              <div class="space-4"></div>

                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="wechat">微信</label>

                                <div class="col-sm-9">
                                  <span>
                                    <input type="text"  id="wechat" name="wechat" />
                                     
                                  </span>
                                </div>
                              </div>

                              <div class="space-4"></div>
                              <h4 class="header blue bolder smaller">财务信息</h4>

                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="bank_name">开户行</label>

                                <div class="col-sm-9">
                                  <span class="input-icon">
                                    <input type="text" value="" id="bank_name" name="bank_name" />
                                     <i class="icon-twitter light-blue"></i>
                                  </span>
                                </div>
                              </div>

                              <div class="space-4"></div>

                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="bank_user">开户名</label>

                                <div class="col-sm-9">
                                  <span class="input-icon">
                                    <input type="text"  id="bank_user" name="bank_user" />
                                     <i class="icon-user light-blue"></i>
                                  </span>
                                </div>
                              </div>
                              <div class="space-4"></div>

                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="bank_num">银行卡号</label>

                                <div class="col-sm-9">
                                  <span class="input-icon">
                                    <input type="text"  id="bank_num" name="bank_num" />
                                     <i class="icon-credit-card light-blue"></i>
                                  </span>
                                </div>
                              </div>

                              <div class="space-4"></div>
                              <h4 class="header blue bolder smaller">密码</h4>
                              <div class="space-10"></div>

                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="password">新密码</label>

                                <div class="col-sm-9">
                                  <input type="password" id="password" name="password"/>
                                </div>
                              </div>

                              <div class="space-4"></div>

                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="password2">确认密码</label>

                                <div class="col-sm-9">
                                  <input type="password" id="password2" name="password2" />
                                </div>
                              </div>

                               
                            </div>

                            <div id="edit-settings" class="tab-pane">
                              <div class="space-10"></div>

                             <!-- <div class="form-group">
                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="member_rank">会员等级:</label>
                                <div class="col-xs-12 col-sm-9">
                                  <div class="clearfix">
                                    <select class="input-medium" id="member_rank" name="member_rank">
                                     <foreach name="rank" item="val">
                                    <option value="{$val.rank_id}">{$val.rank_name}</option>
                                    </foreach>
                                    </select>
                                  </div>
                                </div>
                              </div>-->

                              <div class="space-8"></div>

                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right">开启状态</label>

                                <div class="col-sm-9">
                                  <label class="inline">
                                    <input type="radio" class="ace" name="status" value="0" />
                                    <span class="lbl"> 禁用</span>
                                  </label>

                                  &nbsp; &nbsp; &nbsp;
                                  <label class="inline">
                                    <input type="radio" class="ace" name="status" value="1" checked/>
                                    <span class="lbl"> 开启</span>
                                  </label>
                                </div>
                              </div>

                              <div class="space-8"></div>

                              <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right">代理商</label>

                                <div class="col-sm-9">
                                  <label class="inline">
                                    <input type="radio" class="ace" name="is_agent" value="0" checked />
                                    <span class="lbl"> 否</span>
                                  </label>

                                  &nbsp; &nbsp; &nbsp;
                                  <label class="inline">
                                    <input type="radio" class="ace" name="is_agent" value="1" />
                                    <span class="lbl"> 是</span>
                                  </label>
                                </div>
                              </div>
                              <div class="form-group">
                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="parent_id">上级:</label>
                                <div class="col-xs-12 col-sm-9">
                                  <div class="clearfix" id="select">
                                     <select class="input-medium" name="parent_id" id="parent_id">
                                        
                                     </select>
                                  </div>
                                </div>
                              </div>
                              
                              <!--<div class="form-group">
                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="pan">盘口:</label>
                                <div class="col-xs-12 col-sm-9">
                                  <div class="clearfix" id="select">
                                     <select class="input-medium" name="pan" id="pan">
                                        <option value="A">A盘</option>
                                        <option value="C">C盘</option>
                                     </select>
                                  </div>
                                </div>
                              </div>-->
                            </div>
                            

                             
                          </div>
                        </div>

                        <div class="clearfix form-actions">
                          <div class="col-md-offset-3 col-md-9">
                            <button class="btn btn-info" type="submit" id="submitBtn">
                              <i class="icon-ok bigger-110"></i>
                              保存
                            </button>

                            &nbsp; &nbsp;
                            <button class="btn" type="reset">
                              <i class="icon-undo bigger-110"></i>
                              重置
                            </button>
                          </div>
                        </div>
                       
                    </div><!-- /span -->
                  </div><!-- /user-profile -->
                </div>
      </form>
      <!-- /.table-responsive --> 
    </div>
     <input type="hidden" value="{:U('Admin/Member/ajax',array('branch'=>'check_mobile'))}" id="check_mobile">
     <input type="hidden" value="{:U('Admin/Member/ajax',array('branch'=>'check_name'))}" id="check_name">
     <input type="hidden" value="{:U('Admin/Member/ajax',array('branch'=>'get_parent'))}" id="get_parent">
  </div>
</div>
<include file="Layout/js"/> 
<script src="__ADMIN_JS__/jquery.validate.min.js"></script> 
<link href="__ADMIN_CSS__/datepicker.css" rel="stylesheet" />
<script src="__ADMIN_JS__/date-time/bootstrap-datepicker.min.js"></script>

<script src="__ADMIN_JS__/bootbox.js"></script> 
 
<script type="text/javascript">       
  
      jQuery(function($) {
        $('#user-profile-3')
        .find('input[type=file]').ace_file_input({
          style:'well',
          btn_choose:'选择',
          btn_change:null,
          no_icon:'icon-picture',
          thumbnail:'large',
          droppable:true,
          before_change: function(files, dropped) {
            var file = files[0];
            if(typeof file === "string") { 
              //files is just a file name here (in browsers that don't support FileReader API)
              if(! (/\.(jpe?g|png|gif)$/i).test(file) ) return false;
            }else{ 
              var type = $.trim(file.type);
              if( ( type.length > 0 && ! (/^image\/(jpe?g|png|gif)$/i).test(type) )
                  || ( type.length == 0 && ! (/\.(jpe?g|png|gif)$/i).test(file.name) ) //for android default browser!
                ) return false;
      
              if( file.size > 2097152 ) {  
                alert('上传图片大小超过2M');
                return false;
              }
            }
      
            return true;
          }
        })
        .end().find('button[type=reset]').on(ace.click_event, function(){
          $('#user-profile-3 input[type=file]').ace_file_input('reset_input');
        })
        .end().find('.date-picker').datepicker().next().on(ace.click_event, function(){
          $(this).prev().focus();
        })
      });
 </script>
 <script type="text/javascript">
 // 手机号码验证  
jQuery.validator.addMethod("isMobile", function (value, element) {  
    var length = value.length;  
     var mobile = /^[1][3-8]\d{9}$/;   
    return this.optional(element) || (length == 11 && mobile.test(value));  
}, "请正确填写您的手机号码");  

$(document).ready(function(){
   var host=$("#check_mobile").val();
   var host_name=$("#check_name").val();
  // alert(host);
  $("#submitBtn").click(function(){ 
         $("#validation-form").submit();
  });
  $('#validation-form').validate({
    errorElement: 'div',
    errorClass: 'help-block',
    focusInvalid: false,
        rules : {
                      
            member_name: {
              required: true,
              remote   : {
                    url :host_name,
                    type:'get',
                    data:{
                        member_name : function(){
                            return $('#member_name').val();
                        } 
                    }
                }
            },
			 member_email: {
              email: true,
             },
            member_mobile: {
              required: true,
              isMobile :true,
              remote   : {
                    url :host,
                    type:'get',
                    data:{
                        member_mobile : function(){
                            return $('#member_mobile').val();
                        } 
                    }
                }
            },
            password: {
              required: true,
              minlength: 6
            },
            password2: {
              required: true,
              minlength: 6,
              equalTo: "#password"
            },
             
        },
        messages : {
            member_name: {
              required: "会员名称不能为空",
              remote : '会员账号有重复，请您换一个'
            },
			 member_email: {
              email: "请输入合法的邮箱地址",
             },
            member_mobile: {
              required: "手机号必填" ,
              isMobile   : '请您填写有效的手机号',
              remote : '手机号有重复，请您换一个'
            },
            password: {
              required: "请填写密码",
              minlength: "密码长度不能少于6位数."
            },
            password2: {
              required: "请填写确认密码",
              minlength: "确认密码长度不能少于6位数.",
              equalTo: "两次密码不相同，请重新输入"
            },
             
        },
     
      
          highlight: function (e) {
            $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
          },
      
          success: function (e) {
            $(e).closest('.form-group').removeClass('has-error').addClass('has-info');
            $(e).remove();
          },
      
          errorPlacement: function (error, element) {
            if(element.is(':checkbox') || element.is(':radio')) {
              var controls = element.closest('div[class*="col-"]');
              if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
              else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
            }
            else if(element.is('.select2')) {
              error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
            }
            else if(element.is('.chosen-select')) {
              error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
            }
            else error.insertAfter(element.parent());
          },
      
          submitHandler: function (form) {
            $(form).ajaxSubmit();
                  var index = parent.layer.getFrameIndex(window.name);
                  //parent.$('.btn-refresh').click();
                  parent.layer.close(index);
          }
           
    });
});
    </script>
    <script type="text/javascript">
     $(document).ready(function() {  
                //  加载所有的省份  
        var url=$("#get_parent").val();
                $.ajax({  
                    type: "POST",  
                    url: url, 
                    //data: {"parent_id": "0"},  
                    dataType: "json",  
                    success: function(data) {  
                        $("#parent_id").html("<option value=''>请选择代理商</option>");  
                        $.each(data.member, function(i, item) {  
                            $("#parent_id").append("<option value='" + item.member_id + "'>" + item.member_name + "</option>");  
                        });  
                    }  
                }); 

                 
      });


 
    </script>
</body>
</html>